unit oFramePaths;

{
	created   5.4.2010
	author   	Miroslav Mintal
	purpose
}


interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, oManager, oProcessItem, oProcessObjects,
  oProcessObjectConstants, oLevel, oLogicalEntity, oEntity, oPathsManager;

type
  TFramePaths = class(TFrame)
    txtName: TLabeledEdit;
    btnSave: TButton;
    btnCancel: TButton;
    procedure btnSaveClick(Sender: TObject);
    procedure btnCancelClick(Sender: TObject);
//    procedure btnAddClick(Sender: TObject);
//    procedure btnDelClick(Sender: TObject);
//    procedure btnAddFirstClick(Sender: TObject);
  private
    aManager: TManager;
    { Private declarations }
  public
    property Manager: TManager read aManager write aManager;
   // procedure Init;
    { Public declarations }
  end;

implementation

{$R *.dfm}
{
procedure TFramePaths.btnAddClick(Sender: TObject);
var
  list: TProcessingList;
begin
  list := TProcessingList.Create();
  list.addParameter(TString.Create(txtName.Text));
  list.addParameter(TEntityProcessing.Create(lbxLogEntity.Items.Objects[lbxLogEntity.ItemIndex] AS TEntity));
  list.addParameter(TEntityProcessing.Create(lbxCesta.Items.Objects[lbxCesta.ItemIndex] AS TEntity));
  aManager.Master.ProcessObject(TProcessItem.create(PO_PATHS_INSERT_WAYPOINT, list));
end;
}
{procedure TFramePaths.btnAddFirstClick(Sender: TObject);
var
  list: TProcessingList;
  log: TlogicalEntity;
begin
  list := TProcessingList.Create();
  list.addParameter(TString.Create(txtName.Text));
  log := lbxLogEntity.Items.Objects[lbxLogEntity.ItemIndex] AS TlogicalEntity;
  list.addParameter(TEntityProcessing.Create(log));
  list.addParameter(nil);
  lbxCesta.AddItem(IntToStr(log.Id)+' - '+IntToStr(log.TypeLogic)+' - '+ log.Name, log);
  aManager.Master.ProcessObject(TProcessItem.create(PO_PATHS_INSERT_PATH, TString.Create(txtName.Text)));
  aManager.Master.ProcessObject(TProcessItem.create(PO_PATHS_INSERT_WAYPOINT, list));
end;
}
procedure TFramePaths.btnCancelClick(Sender: TObject);
begin
//  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_PATHS_CANCEL, nil));
end;
{
procedure TFramePaths.btnDelClick(Sender: TObject);
var
  list: TProcessingList;
begin
  list := TProcessingList.Create();
  list.addParameter(TString.Create(txtName.Text));
  list.addParameter(TEntityProcessing.Create(lbxCesta.Items.Objects[lbxCesta.ItemIndex] AS TEntity));
  aManager.Master.ProcessObject(TProcessItem.create(PO_PATHS_REMOVE_WAYPOINT, list));
  lbxCesta.Items.Delete(lbxCesta.ItemIndex);
end;
}
procedure TFramePaths.btnSaveClick(Sender: TObject);
begin
  aManager.ProcessObject(TProcessItem.create(PO_EDITOR_PATHS_SAVE, nil));

end;

{procedure TFramePaths.Init;
var
  level: Tlevel;
  log: TlogicalEntity;
  path: TPathsManager.TPathType;
  entita: TEntity;
  test : TProcessingObject;
begin
  level := (aManager.Master.ProcessObject(TProcessItem.create(PO_SCENE_GET_LEVEL, nil)).Data AS TprocessingLEvel).Level;
  for log in level.AllLogicalEntities do
  begin
    lbxLogEntity.AddItem(IntToStr(log.Id)+' - '+IntToStr(log.TypeLogic)+' - '+ log.Name, log);
  end;
  test := aManager.Master.ProcessObject(TProcessItem.create(PO_PATHS_GET_PATH, TString.Create(txtName.Text))).Data;
  if Assigned(test) then
  begin
    path := (test AS TProcessingPath).Path AS TPathsManager.TPathType;
    for entita in path.WayPoints do
    begin
      log := entita AS TLogicalEntity;
      lbxCesta.AddItem(IntToStr(log.Id)+' - '+IntToStr(log.TypeLogic)+' - '+ log.Name, log);
    end;
  end;
end;
}
end.
